//
//  CYBaseViewController.h
//  SafetyInHand
//
//  Created by admin on 2022/7/29.
//

#ifndef CYBaseConst_h
#define CYBaseConst_h

typedef enum : NSUInteger {
    RefreshViewStateNormal = 0,
    RefreshViewStateWillLoad,
    RefreshViewStateLoading,
    RefreshViewStateLoaded,
} RefreshViewState;

#define degreesToRadian(x) (M_PI * (x) / 180.0)

//Window
#define KEY_WINDOW  [[UIApplication sharedApplication].delegate window]
#define MAIN_SCREEN [UIScreen mainScreen]
#define SCREEN_SCALE [UIScreen mainScreen].scale

//Orientation
#define SCREEN_ORIENTATION [[UIApplication sharedApplication] statusBarOrientation]
#define IS_SCREEN_PORTRAIT (SCREEN_ORIENTATION == UIInterfaceOrientationPortrait)

//CacheFolder
#define kCachePath [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]
#define kDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]
#define FOLDER_PATH_WITH_FOLDER_NAME(folder) [kCachesPath stringByAppendingPathComponent:folder]

//NSString
#define EMPTY_STR @""
#define STR_IS_NULL_OR_EMPTY(str)       (str == nil || [str isEqualToString:EMPTY_STR] || [str isEqual:[NSNull null]])
#define STR_IS_NOT_NULL_OR_EMPTY(str)   (str != nil && ![str isEqualToString:EMPTY_STR] && ![str isEqual:[NSNull null]])

//UIColor
#define RGBA_COLOR(r,g,b,a)  [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

//UIDevice
#define IS_IPAD ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
#define IS_320Screen (MAIN_SCREEN.bounds.size.width == 320)

#define IOS_AVAILABLE_EQUAL_OR_LOW(version) ([UIDevice currentDevice].systemVersion.floatValue <= version) // 小于或等于某版本
#define IOS_AVAILABLE_EQUAL_OR_HIGH(version) ([UIDevice currentDevice].systemVersion.floatValue >= version) // 大于或等于某版本

//NSURL
#define URL_WITH_STR(str)           [NSURL URLWithString:str]
#define FILE_URL_WITH_STR(str)      [NSURL fileURLWithPath:str]

//弧度转角度
#define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI))

//角度转弧度
#define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)

//NSLog
#ifdef CY_BASE_KIT_DEBUG
#define CYLog(...) NSLog(__VA_ARGS__)
#else
#define CYLog(...)
#endif

//CommonBlock
typedef void(^CompletedBlock)();

#endif